<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>更新机构信息</title>
<link rel="stylesheet" type="text/css" href="css/css.css" />
<script type="text/javascript" src="js/jquery.min.js"></script>
<style>
	
	td{border:0px}
	.bbD .td{
		font-size: 16px;
		text-aign:right;
	}
	.text2{
		font-size: 16px;
		text-aign:right;
		width: 300px;
	}
	.button{
			margin-top:20px;
			font-size: 16px;
			width: 135px;
			height: 40px;
			border-radius:20px;
			border: 1px solid #ccc;
			margin-left: 35px;
			color: #fff;
			background-color: #47a4e1
	}

</style>
<script type="text/javascript">

	

	/* 验证机构是否存在 */
		function checkOrganame(){
			$("#spaninfo").html("");
		 	var orgname=$("#orgname").val();
		 	var reg=/^(?=.*?[\u4E00-\u9FA5])[\dA-Za-z\u4E00-\u9FA5]+(?=.*?[\u4E00-\u9FA5])/;
			if(orgname==null || ""==orgname){
				$("#spaninfo").html("机构名称不能为空").css({color:"red"});
				return false;
			}else if(!reg.test(orgname)){
				$("#spaninfo").html("机构名称不能全是数字或字母，必须要有汉字").css({color:"red"});
				return false;
			}
			return true;	
		}
	
		/* 机构地址不能为空验证 */
		function checkAddress(){
			$("#addressinfo").html("");
			var address=$("#address").val();
			var reg=/^(?=.*?[\u4E00-\u9FA5])[\dA-Za-z\u4E00-\u9FA5]+(?=.*?[\u4E00-\u9FA5])/;
			if(address==null ||""==address){
				$("#addressinfo").html("机构地址不能为空").css({color:"red"});
				return false;
			}else if(!reg.test(address)){
				$("#addressinfo").html("地址不能全是数字或字母，必须要有汉字").css({color:"red"});
				return false;
			}
			return true;
			
		}
		/* 验证邮政编码 */
		function checkCode(){
			$("#codeinfo").html("");
			var code=$("#code").val();
			var reg = /^\d+$/;
			if(code==null ||""==code){
				$("#codeinfo").html("邮政编码不能为空！").css({color:"red"});
				return false;
			}else if(!reg.test(code)){
				$("#codeinfo").html("邮政编码必须是数字").css({color:"red"});
				return false;
			}else if(code.length!=6){
				$("#codeinfo").html("邮政编码必须是6位数字").css({color:"red"});
				return false;
			}else{
				//$("#codeinfo").html("邮政编码可用").css({color:"green"});
				return true;
			}
		}
		/* 网址的验证 */
		function checkNet(){
			$("#netinfo").html("");
			var net = $("#net").val();
			var reg= /^(http(s)?:\/\/)?(www\.)?[\w-]+\.\w{2,4}(\/)?$/;
			if(net==null ||""==net){
				$("#netinfo").html("网址不能为空").css({color:"red"});
				return false;
			}else if(!reg.test(net)){
				$("#netinfo").html("网址格式不符合要求").css({color:"red"});
				return false;
			}else{
				//$("#netinfo").html("网址格式符合要求").css({color:"green"});
				return true;
			}	
		}
	
	
		 function isExsit(){
			if(checkOrganame() && checkAddress() && checkCode() && checkNet() ){
				return true;
			}else{
				return false;
			}
		}
		
		
</script>
</head>
<body>
	<div id="pageAll">
		<div class="pageTop">
			<div class="page">
				<img src="img/coin02.png" /><span><a href="main.do">首页</a>&nbsp;-&nbsp;
				<a href="infomanage.do">机构管理</a>&nbsp;-</span>&nbsp;机构修改
			</div>
		</div>
		<div class="page ">
			<!-- 上传广告页面样式 -->
			<div class="banneradd bor">
				<form action="udpateOrganization.do?id=${organ.id}" method="post" onsubmit="return isExsit()">
				<div class="baTopNo">
					<span>基本信息</span>
					<hr/>
				</div>
				<div class="baBody" >
					<table class="infotable">	
						<tr class="bbD"  >
							<td class="td">机构名称：</td><td ><input type="text" class="input3" onblur="checkOrganame()" id="orgname" name="name" value="${organ.name}"/></td>
							<td><span id="spaninfo"></span></td>					
						</tr>
						<tr class="bbD">
							<td class="td">机构地址：</td><td><input type="text" class="input3" name="address"  id="address" value="${organ.address }" onblur="checkAddress()" /></td>
							<td><span id="addressinfo"></span></td>
						</tr>
						<tr class="bbD">
							<td class="td">手机号码：</td><td><input type="text" class="input3" name="phone" value="${organ.contact.phone }" disabled="disabled"/></td>
						</tr>
						<tr class="bbD" >
							<td class="td">联系人姓名：</td><td><input type="text" class="input3" value="${organ.contact.name }" disabled="disabled"/></td>
							 <td class="td" style="display:none">cid：</td><td style="display:none"><input type="text" class="input3" name="cid" id="cid" value="${organ.contact.id }" /></td> 
						</tr>
						
						
						<tr class="bbD">
							<td class="td">省份：</td><td><input type="text" class="input3" name="province" id="province" value="${organ.province }"/></td>
						</tr>
						<tr class="bbD">
							<td class="td">地级市/区：</td><td><input type="text" class="input3" name="city" value="${organ.city }"/></td>
						</tr>   
						
						<tr class="bbD">
							<td class="td">邮编：</td><td><input class="input3" type="text" name="code" id="code" value="${organ.code }" onblur="checkCode()"/></td>
							<td><span id="codeinfo"></span></td>
						</tr>
						<tr class="bbD">
							<td class="td">网站：</td><td><input class="input3"type="text" name="net" id="net" value="${organ.net }" onblur="checkNet()" /></td>
							<td><span id="netinfo"></span></td>
						</tr>
						<tr class="bbD">
							<td class="td">机构类别：</td>
							<td>
								<select class="input3" name="type">
									<option value="1" <c:if test="${organ.type==1 }">checked="checked"</c:if> >政府</option>
									<option value="2" <c:if test="${organ.type==2 }">checked="checked"</c:if> >学校</option>
									<option value="3" <c:if test="${organ.type==3 }">checked="checked"</c:if> >企业</option>
									<option value="4" <c:if test="${organ.type==4 }">checked="checked"</c:if> >其他</option>
								</select>
							</td>
						</tr>
						<tr class="bbD">
							<td class="td">重要级别：</td>
							<td>
								<select class="input3" name="vip">
									<option value="1" <c:if test="${organ.vip==1 }">checked="checked"</c:if> >一般</option>
									<option value="2" <c:if test="${organ.vip==2 }">checked="checked"</c:if> >重要</option>
									<option value="3" <c:if test="${organ.vip==3 }">checked="checked"</c:if> >非常重要</option>
								</select>
							</td>
						</tr>
						<tr class="bbD">
							<td class="td">审核状态：</td>
							<td>
								<select class="input3" name="checkstate">
									<option value="0" <c:if test="${organ.checkstate==0 }">checked="checked"</c:if> >未审核</option>
									<option value="1" <c:if test="${organ.checkstate==1 }">checked="checked"</c:if> >已审核</option>	
								</select>
							</td>
						</tr>
						<tr class="bbD">
							<td class="td">备注信息：</td>
							<td class="btext2">
								<textarea class="text2" name="remark">${organ.remark }</textarea>
							</td>
						</tr>
					</table>	
				</div>	
					&nbsp;&nbsp;&nbsp;&nbsp;
					<input class="button" type="submit" value="提交" id="tijiao" />
					<button class="button">返回</button>
				</form>
			</div>

			<!-- 上传广告页面样式end -->
		</div>
	</div>
</body>
</html>